// 导入数据库API
const db = require("../../config/db");
module.exports = {
    //获取商品列表
    indexList() {
        return new Promise((resolve, reject) => {
            let sql = "select * from index_product";
            db.query(sql, (err, rows) => {
                if (err) {
                    reject({
                        code: -1,
                        msg: "获取商品列表失败。",
                    });
                } else {
                    resolve({
                        code: 200,
                        msg: "获取商品列表成功。",
                        data: rows,
                    });
                }
            });
        });
    },
    //获取轮播图
    bannerList() {
        return new Promise((resolve, reject) => {
            let sql = "select * from db_banner";
            db.query(sql, (err, rows) => {
                if (err) {
                    reject({
                        code: -1,
                        msg: "获取轮播图失败。",
                    });
                } else {
                    resolve({
                        code: 200,
                        msg: "获取轮播图成功。",
                        data: rows,
                    });
                }
            });
        });
    },
};
